<?php
namespace app\api\controller;
use think\Controller;
use think\facade\Cache;
use think\facade\Request;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/6/006
 * Time: 11:53
 */
class BaseController extends Controller {

    public function initialize() {
        header('Access-Control-Allow-Origin:*');
        header("Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept,USER_ID,TOKEN");
        header("Access-Control-Allow-Methods:HEAD, GET, POST, DELETE, PUT, OPTIONS");
    }

    /**
     * 清除缓存
     */
    public function clear_cache() {
        Cache::clear();
        return json(['msg' => '清理成功', 'url' => Request::url()]);
    }
}